import pendulum

from trader.market.stock import excute_batch_fetch_stock
from trader.tools import timex
from trader.data.stock import CustomDataFrame
from trader.tools import market


if __name__ == "__main__":
    start_date = timex.dt_to_date(pendulum.now().subtract(months=4))
    level = market.K_30m

    stock_codes = CustomDataFrame.into_code_list("fs/stock_code.csv")
    excute_batch_fetch_stock(
        stock_codes=stock_codes,
        start_date=start_date,
        interval=level,
        mode="single",
    )

    print("🚀 Fetching kline data is done.")
